package com.jzmy.cultivate.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jzmy.cultivate.entity.Consultations;
import com.jzmy.cultivate.entity.vo.ConsultationsVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author mengzhichao
 * @create 2022-08-25-9:32
 */
public interface ConsultationsDao extends BaseMapper<Consultations> {

    @Select("SELECT id,first_column as firstColum,second_column as secondColumn,title,files,thumbnail,access_number as accessNumber,creater_date as createrDate " +
            " FROM jz_consultations where state=1 ORDER BY id desc")
    List<ConsultationsVo> dyGetUserList1(Page<ConsultationsVo> page);

    @Select("SELECT id,first_column as firstColum,second_column as secondColumn,title,files,thumbnail,access_number as accessNumber,creater_date as createrDate , " +
            "istop FROM jz_consultations where second_column=#{columnName} and first_column=#{firstColumn} and state=1 ORDER BY istop =1  desc  , creater_date desc")
    List<ConsultationsVo> dyGetUserList2(Page<ConsultationsVo> page, @Param("firstColumn") String firstColumn, @Param("columnName") String columnName);


    @Select("SELECT id,first_column as firstColum,second_column as secondColumn,title,files,thumbnail,access_number as accessNumber,creater_date as createrDate " +
            " FROM jz_consultations where first_column=#{firstColumn} and state=1 ORDER BY id desc")
    List<ConsultationsVo> dyGetUserList3(Page<ConsultationsVo> page, @Param("firstColumn") String firstColumn);

    @Select("SELECT id,first_column as firstColum,second_column as secondColumn,title,files,thumbnail,access_number as accessNumber,creater_date as createrDate " +
            " FROM jz_consultations where state=1 and title like concat('%',#{title},'%') ORDER BY id desc")
    List<ConsultationsVo> dyGetUserList4(Page<ConsultationsVo> page, @Param("title") String title);


    @Select("SELECT id,first_column as firstColum,second_column as secondColumn,title,files,thumbnail,access_number as accessNumber,creater_date as createrDate , " +
            "istop FROM jz_consultations where second_column in ('职业技能等级标准','考核评分标准','课程标准') and first_column=#{firstColumn} and state=1 ORDER BY istop =1  desc  , creater_date desc")
    List<ConsultationsVo> dyGetUserList5(Page<ConsultationsVo> page, @Param("firstColumn") String firstColumn, @Param("columnName") String columnName);
}
